package com.baomidou.springwind.test.IO;

import com.baomidou.springwind.test.TextFile;

import java.io.*;
import java.util.HashMap;
import java.util.Map;
import java.util.TreeSet;

/**
 * Created by Administrator on 2017/2/26.
 */
public class Count {
    private static Map<Character, Integer> map = new HashMap<Character, Integer>();


    public static void main(String[] args) throws IOException {
//        TreeSet<String> stringTreeSet = new TreeSet<String>(new TextFile("F:\\code\\SpringWind\\SpringWind\\src\\main\\java\\com\\baomidou\\springwind\\test\\IO\\yhx.txt", "[a-zA-Z]"));
//        System.out.println(stringTreeSet.headSet("a"));
        byte[] bytes = new byte[1024];
        BufferedReader in = new BufferedReader(new StringReader(BufferedInputFile.read("F:\\code\\SpringWind\\SpringWind\\src\\main\\java\\com\\baomidou\\springwind\\test\\IO\\yhx.txt")));

        int i;
        while ((i = in.read()) != -1) {
            if (map.get((char) i) == null) {
                map.put((char) i, 1);
            } else {
                Integer num = map.get((char) i);
                map.put((char) i, ++num);
            }
        }
        in.close();
        System.out.println(map);
    }

}
